package com.example.controller;

import com.example.pojo.AttractionResult;
import com.example.pojo.Result;
import com.example.service.AttractionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/attraction")
public class AttractionController {

    @Autowired
    private AttractionService attractionService;

    @GetMapping
    public Result<Result.ResponseData<AttractionResult>> getTopAttractions() {
        // 1. 调用Service获取热门景点数据
        AttractionResult attractionResult = attractionService.getTopAttractions();

        // 2. 构建响应体（code=1000，msg=success，data=封装后的leftSrc和rightSrc）
        Result.ResponseData<AttractionResult> responseData = new Result.ResponseData<>();
        responseData.setCode(1000);
        responseData.setMsg("success");
        responseData.setData(attractionResult);

        // 3. 用Result包装并返回
        return Result.success(responseData);
    }
}